package com.greedy;

import java.util.Arrays;

public class Solution03 {
    public int wiggleMaxLength(int[] nums) {
        int pre = 0;
        int cur;
        int count = 1;
        for (int i = 1; i < nums.length; i++) {
            cur = nums[i] - nums[i-1];
            if ((cur>0&&pre<=0) || (cur<0&&pre>=0)) {
                count++;
                pre = cur;
            }
        }
        return count;
    }
}
